
<div>
    <ul class="list-group">
        <li class="list-group-item">免费域名注册</li>
        <li class="list-group-item">免费 Window 空间托管</li>
        <li class="list-group-item">图像的数量</li>
        <li class="list-group-item">24*7 支持</li>
        <li class="list-group-item">每年更新成本</li>
    </ul>

    <h3>测试验证码和token</h3>
    kkkklklsklfklsdkkl
    kslkdfklsklfdkskdfkls
    <form action="" method="post">
        <input type="text" name="num" id="num"/>
        <img class="one" src="<?php echo U('Base/getCode')?>" data-id="<?php echo session('authnum')?>"/>
        <button type="button">commit</button><br/>
        <input type="hidden" name="token" id="token" value="<?php echo md5($token)?>" />
    </form>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        var num = $('img.one').attr('data-id');
        num = parseInt(Math.random() * (9999 - 1000 + 1) + 1000);
        $('img.one').attr('src',"<?php echo U('Base/getCode').'?num='?>"+num);
        $('img.one').attr('data-id',num);

        $('img.one').click(function(){
            num = parseInt(Math.random() * (9999 - 1000 + 1) + 1000);

            $('img.one').attr('src',"<?php echo U('Base/getCode').'?num='?>"+num);
            $('img.one').attr('data-id',num);
        })
        $('button').click(function(){
            var value = $('input#num').val();
            var token = $('input#token').attr('value');

            $.post("<?php echo U('Base/test')?>",{num:value,token:token},function(res){
                if(res==1){
                    alert('验证成功');
                    window.location.href='<?php echo U("test")?>';
                }
                else{
                    alert('验证失败');
                }
            })
        })
    })

</script>

